package com.cloudbroker.openapi.mobile.controller;

import static com.cloudbroker.bcs.platform.dav.common.util.RequestUtil.getSingleParameterMapForBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloudbroker.bcs.common.entity.HSBCPSBackNumVO;
import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.result.QuestionListResult;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.result.TenantQuestionListResult;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.QuesAnsListForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.QuesAskForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.QuesAskNumForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.QuestionIdForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.question.vo.TenantQuesAskForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.viewpoint.vo.TenantKeyListQryForm;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.business.QuestionAnswerT2BizService;
import com.cloudbroker.bcs.platform.dav.common.ext.annotation.SaveLog;

/**
 * Created by zhaojp18008 on 2016/5/10.
 */
@Controller
public class AskAndAnswerController {

    @Resource
    private QuestionAnswerT2BizService questionAnswerT2;
    /**
     * 问与答列表
     * */
    @ResponseBody
    @RequestMapping("/func_question_answer_list_by_fans")
    @SaveLog(remark = "问与答列表")
    public QuestionListResult funcQuestionAnswerList(HttpServletRequest request , String jsonpcallback){
        QuesAnsListForm form = getSingleParameterMapForBody(request , QuesAnsListForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcQuestionAnswerListByFans(form), jsonpcallback);
    }
    
    /**
     * 多投顾问与答列表
     * */
    @ResponseBody
    @RequestMapping("/func_question_answer_list_by_tenant")
    @SaveLog(remark = "多投顾问与答列表")
    public TenantQuestionListResult funcQuestionAnswerListByTenant(HttpServletRequest request , String jsonpcallback){
        TenantKeyListQryForm form = getSingleParameterMapForBody(request , TenantKeyListQryForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcQuestionAnswerListByTenant(form), jsonpcallback);
    }
    
    /**
     * 提问
     * */
    @ResponseBody
    @RequestMapping("/func_question_ask")
    @SaveLog(remark = "提问")
    public HSBCPSBackVO  funcAskQuestion(HttpServletRequest request , String jsonpcallback){
        QuesAskForm quesAskForm = getSingleParameterMapForBody(request , QuesAskForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcAskQuestion(quesAskForm), jsonpcallback);
    }
    
    /**
     * 多投顾提问
     * */
    @ResponseBody
    @RequestMapping("/func_question_ask_by_tenant")
    @SaveLog(remark = "提问")
    public HSBCPSBackVO funcAskQuestionByTenant(HttpServletRequest request , String jsonpcallback){
        TenantQuesAskForm quesAskForm = getSingleParameterMapForBody(request , TenantQuesAskForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcAskQuestionByTenant(quesAskForm), jsonpcallback);
    }
    
    /**
     * 被回答问题个数
     * */
    @ResponseBody
    @RequestMapping("/func_answerd_num")
    @SaveLog(remark = "被回答问题个数")
    public HSBCPSBackNumVO funcAnswerdNum(HttpServletRequest request , String jsonpcallback){
        QuesAskNumForm form = getSingleParameterMapForBody(request , QuesAskNumForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcAnswerdNum(form), jsonpcallback);
    }
    
    /**
     * 粉丝删除自己的提问
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_fans_question_del")
    @SaveLog(remark = "粉丝删除自己的提问")
    public HSBCPSBackVO funcQuestionDel(HttpServletRequest request , String jsonpcallback){
        QuestionIdForm form = getSingleParameterMapForBody(request , QuestionIdForm.class);
        return VOUtil.setJsonpResult(questionAnswerT2.funcFansQuestionDel(form), jsonpcallback);
    }

}
